package com.aurora.spider.gitee;

import com.geccocrawler.gecco.annotation.PipelineName;
import com.geccocrawler.gecco.pipeline.Pipeline;
import com.geccocrawler.gecco.request.HttpRequest;
import com.geccocrawler.gecco.scheduler.StartSchedulerContext;
import com.geccocrawler.gecco.spider.HrefBean;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * Created by jackie on 18/1/15.
 */
@PipelineName("giteeAllSortPipeline")
@Slf4j
public class AllSortPipeline implements Pipeline<AllSort> {
    @Override
    public void process(AllSort allSort) {
        //根据页码 再次迭代 ，目前直接5页 todo
        List<HitProject> projectList = allSort.getProjectList();
        for (HitProject hitProject : projectList) {
            List<HrefBean> hrefs = hitProject.getUrls();
            for(HrefBean href : hrefs) {
                String url = href.getUrl();
                HttpRequest currRequest = allSort.getRequest();
                StartSchedulerContext.into(currRequest.subRequest(url));
            }
        }
    }
}
